//% color="#00c4dd" iconWidth=50 iconHeight=40
namespace unihiker_sound{



    //% block="行空板音量设置为[SOUND]%" blockType="command" 
    ///% SOUND.shadow="range"   SOUND.params.min=0    SOUND.params.max=100    SOUND.defl=100
    export function unihiker_setsound_init(parameter: any, block: any){
        let SOUND = parameter.SOUND.code;

        Generator.addImport("from unihiker_sound import *");
        Generator.addDeclaration("unihiker_sound",`unihiker_sound = SoundManager()`)
        Generator.addCode(`unihiker_sound.set_volume(${SOUND})`)


    }

    
    //% block="获取行空板音量" blockType="reporter"
    export function unihiker_getsound(parameter: any, block: any){
        Generator.addImport("from unihiker_sound import *");
        Generator.addDeclaration("unihiker_sound",`unihiker_sound = SoundManager()`)   
        Generator.addCode(`unihiker_sound.get_volume()`)
    }

        //% block="---"
        export function noteSep2() {

        }
    //% block="查询当前音频【输入/输出】设备列表"blockType="command" 
 
    export function unihiker_init_list(parameter: any, block: any){
        // let sound_de = parameter.DE.code;
        Generator.addImport("from unihiker_sound import *");
        Generator.addDeclaration("unihiker_sound",`unihiker_sound = SoundManager()`)
        Generator.addCode(`unihiker_sound.get_device_list()`)
    }


    //% block="设置当前系统音频[DE_SET]设备系统名称[SOUND_ID]"blockType="command" 
    //% DE_SET.shadow="dropdown" DE_SET.options="DE_SET"
    //% SOUND_ID.shadow="string" SOUND_ID.defl="alsa_input.platform-acodec-sound.stereo-fallback"
    export function unihiker_init(parameter: any, block: any){
        let sound_de = parameter.DE_SET.code;
        let sound_id = parameter.SOUND_ID.code;

        Generator.addImport("from unihiker_sound import *");
        Generator.addDeclaration("unihiker_sound",`unihiker_sound = SoundManager()`)
        Generator.addCode(`unihiker_sound.set_default_${sound_de}_device_by_name(${sound_id})`) 
    }

}